package com.ctbri.vSearch.util;

import org.apache.log4j.Logger;
import org.springframework.core.io.support.PropertiesLoaderUtils;

import java.io.IOException;
import java.util.Properties;

/**
 * 配置文件工具类
 * 
 * @author Hogan
 * 
 */
public class PropUtil {

	private static Logger log = Logger.getLogger(PropUtil.class);

	private static String propPath = "config.properties";

	public PropUtil(String propPath) {
		PropUtil.propPath = propPath;
	}

	/**
	 * 根据Key获取对应的Value
	 * 
	 * @param key
	 * @return
	 */
	public static String getValue(String key) {
		Properties prop = new Properties();
		try {
			prop = PropertiesLoaderUtils.loadAllProperties(propPath);
			return prop.getProperty(key);
		} catch (IOException e) {
			log.error("打开配置文件失败!文件路径为:" + propPath, e);
			return null;
		}
	}

}
